package dormouse.vfs.ui.renderers;

import java.util.List;

import org.apache.commons.vfs2.FileObject;

import com.google.common.base.Predicate;

import dormouse.vfs.event.IFileSelectionListener;
import dormouse.vfs.event.ILocationChangeListener;

/**
 * Implementations of this interface are responsible for rendering a list of
 * FileObjects, or a directory.  Whenever the user selects a file from the file list,
 * this will notify all registered IFileSelectionListeners that a selection has been made.
 * 
 * 
 * @param <C>
 *            the type of component to be returned. This is a java.awt.Component
 *            in Swing, but may be other types with other toolkits.
 */
public interface IFileListRenderer<C> extends ILocationChangeListener{

	/**
	 * This method gets the name of the file list renderer. The name is used in
	 * a combo box.
	 * 
	 * @return
	 */
	String toString();

	/**
	 * This method causes a renderer to render all of the children of a specific
	 * directory.
	 * 
	 * @param dir
	 *            the directory to be rendered.
	 * @param predicate
	 *            an optional predicate used to filter the list of files.
	 */
	void render(FileObject dir, Predicate<FileObject> predicate);

	/**
	 * This method causes a renderer to render all of the children of a specific
	 * directory.
	 * 
	 * @param dir
	 *            the directory to be rendered.
	 * @param predicate
	 *            an optional (nullable) predicate used to filter the list of
	 *            files found at the directory.
	 */
	void render(String dir, Predicate<FileObject> predicate);

	/**
	 * 
	 * @param fileList
	 * @param predicate
	 */
	void render(List<FileObject> fileList, Predicate<FileObject> predicate);

	/**
	 * This method gets the component.
	 * 
	 * @return
	 */
	C getComponent();

	/**
	 * This method is responsible for notifying all of the registered file
	 * selection listeners.
	 * 
	 * @param selectedFile
	 *            The selected file.
	 */
	void notifyFileSelectionListeners(FileObject selectedFile);

	/**
	 * This method adds a IFileSelectionListener to the renderer.
	 * 
	 * @param listener
	 *            The listener to be added.
	 */
	void addFileSelectionListener(IFileSelectionListener listener);

	/**
	 * This method removes the selected IFileSelectionListener
	 * 
	 * @param listener
	 *            The listener to be removed.
	 */
	void removeFileSelectionListener(IFileSelectionListener listener);

	/**
	 * This method removes all FileSelectionListeners.
	 */
	void removeAllFileSelectionListeners();

	/**
	 * Gets a constant name used to retrieve an instance of the renderer from
	 * the factory.
	 * 
	 * @return the name of the renderer.
	 */
	String getName();
}
